package com.example.demothree.service.imp;

import com.example.demothree.bean.SaleOrder;
import com.example.demothree.bean.SaleReturnOrder;
import com.example.demothree.dao.SaleOrderDao;
import com.example.demothree.dao.SaleReturnOrderDao;
import com.example.demothree.service.SaleService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class SaleServiceImp implements SaleService {
    @Resource
    private SaleReturnOrderDao saleReturnOrderDao;
    @Resource
    private SaleOrderDao saleOrderDao;
    @Override
    public Page<SaleOrder> saleXsdd(Integer page, Integer size) {
        Pageable pageable = PageRequest.of(page,size);
        Page<SaleOrder> pagesalexsdd = saleOrderDao.findAll(pageable);
        return pagesalexsdd;
    }
    //添加销售订单
    @Override
    public SaleOrder addxsdd(SaleOrder saleOrder) {
        return saleOrderDao.save(saleOrder);
    }
    //删除销售订单
    @Override
    public void deletexsdd(Long id) {
        saleOrderDao.deleteById(id);
    }
    @Override
    public Page<SaleOrder> saleFhck(Integer page,Integer size) {
        Pageable pageable = PageRequest.of(page,size);
        Page<SaleOrder> pagesalefhck = saleOrderDao.findAll(pageable);
        return pagesalefhck;
    }
    @Override
    public Page<SaleReturnOrder> saleXsth(Integer page, Integer size) {
        Pageable pageable = PageRequest.of(page,size);
        Page<SaleReturnOrder> pagesalexsth = saleReturnOrderDao.findAll(pageable);
        return pagesalexsth;
    }
    //添加退货订单
    @Override
    public SaleReturnOrder addxsth(SaleReturnOrder saleReturnOrder) {
        return saleReturnOrderDao.save(saleReturnOrder);
    }
    //id查询退货订单
    @Override
    public SaleOrder findById(Long id) {
        return saleOrderDao.findBy(id);
    }
    //删除退货订单
    @Override
    public void deletexsth(Long id) {
        saleReturnOrderDao.deleteById(id);
    }
}
